const Mock = require('mockjs')

const CarManageList=[];
for(let i=0;i<100;i++){
    CarManageList.push(
        Mock.mock({
            id:'@increment',
            licenseplate:'@integer(10000,99999)',
            carname:'@first',
            carcolor:'@color',
            buyinshop:'@integer(0,1)',
            buydate:'@datetime',
            customername:'@first',
            'customertype|1':['公司','个人'],
            customerphone:'@integer(13500001111,13790001111)',
            productiondate:'@datetime',
            onaccount:'@first',
            discount:'@integer(0,1)',
            state:'@integer(0,1)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const CarFixhistoryList=[];
for(let i=0;i<100;i++){
    CarFixhistoryList.push(
        Mock.mock({
            id:'@increment',
            fixnumber:'@integer(10000,99999)',
            fixtype:'@integer(1,3)',
            fixdate:'@datetime',
            guider:'@first',
            refix:'@integer(0,1)',
            state:'@integer(0,1)',
            actualmoney:'@integer(10000,99999)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const InsuranceList=[];
for(let i=0;i<100;i++){
    InsuranceList.push(
        Mock.mock({
            id:'@increment',
            insurancenumber:'@integer(10000,99999)',
            type:'@integer(1,3)',
            commerce:'@integer(1000,9999)',
            compulsory:'@integer(1000,9999)',
            vvtax:'@integer(100,999)',
            give:'@integer(10,1000)',
            guider:'@first',
            state:'@integer(0,1)',
            actualmoney:'@integer(10000,99999)',
            totalmoney:'@integer(10000,99999)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const ExtrapartsList=[];
for(let i=0;i<100;i++){
    ExtrapartsList.push(
        Mock.mock({
            id:'@increment',
            ordernumber:'@integer(10000,99999)',
            ordertype:'@integer(1,3)',
            boutiquename:'@first',
            boutiquecount:'@integer(1,100)',
            guider:'@first',
            state:'@integer(0,1)',
            actualmoney:'@integer(10000,99999)',
            totalmoney:'@integer(10000,99999)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

module.exports=[
    {
        url: '/api/aftersale/carmanagelist',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = CarManageList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/fixhistory',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = CarFixhistoryList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/insurance',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = InsuranceList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/extraparts',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = ExtrapartsList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
]